{% if field_value %}
  {% set need_weight = field_value|rejectattr("weight")|list|length > 0 %}
  <table class="table table-bordered table-condensed">
    <thead>
    <tr>
      {% if need_weight %}
        <th></th>
      {% endif %}
      <th>编号</th>
      <th>装卸点</th>
      <th>客户</th>
      <th>装卸工</th>
      <th>全部卸货</th>
      <th>产品</th>
      <th>图片</th>
      <th>重量(公斤)</th>
    </tr>
    </thead>
    <tbody>
    {% for row in field_value %}
      <tr>
        {% if need_weight %}
          <td>
            {% if not row.weight %}
              <a class="del-ut" href="#" data-pk={{ row.id }}><i class="fa fa-times text-danger"></i></a>
            {% endif %}
          </td>
        {% endif %}
        <td>
          {% if row.weight %}
            <a href={{ url_for("cargo.unload_task", id_=row.id, url=request.url) }}>{{ row.id }}</a>
          {% else %}
            {{ row.id }}
          {% endif %}
        </td>
        <td>{{ row.harbor }}</td>
        <td>{{ row.customer }}</td>
        <td>{{ row.creator }}</td>
        <th>{% if row.is_last %}是{% else %}否{% endif %}</th>
        <td>{{ row.product }}</td>
        <td>
          {% if row.pic_path %}
            <a class="fancybox thumbnail" href="{{ row.pic_url }}" rel="group" title="{{ row.product.name }}">
              <img class="img-responsive img-polaroid" src="{{ row.pic_url }}" alt="{{ row.product.name }}"/>
            </a>
          {% endif %}
        </td>
        <td>
          {% if row.weight %}
            {{ row.weight }}
          {% else %}
            <a class="btn btn-primary" href="{{ url_for('cargo.weigh_unload_task', id_=row.id, url=request.url) }}">称重</a>
          {% endif %}
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
  <script type="text/javascript">
    $(function () {
      $("a.del-ut").click(function () {
        if (confirm("您确认要删除卸货任务" + $(this).attr("data-pk") + "?")) {
          $.post("/cargo/ajax/unload-task/" + $(this).attr("data-pk"), {"action": "delete"},
              function () {
                window.location.reload(false);
              });
        }
      });
    });
  </script>
{% else %}
  <span class="text-danger">无</span>
{% endif %}